var DBTools = {}
var DBCache = {}
DBTools.prepareDB = function(path){
    cc.loader.loadRes(path, function(err,res){  
        if (err) {  
            cc.log(err); 
        }else{
            DBCache[path] = res  
        }  
    });
}

DBTools.getDB = function(path){
   return DBCache[path]
}

DBTools.getDBCardById = function(id){
    var db = DBCache['Jsons/cards']
    for(var i = 0; i < db.length; i++){
        if(db[i].id == id){
            return db[i]
        }
    }
}

DBTools.Debug_CreateGamePlayer = function(id){
    var GamePlayer = require("../Model/GamePlayer")
    var instance = new GamePlayer(id)
    instance.cardGroup = [1,1,1,1,2,2,2,2]
    return instance
}

module.exports = DBTools